package com.joejag.mavenstats.client.service;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
import com.joejag.mavenstats.client.dto.ReportDTO;

import java.util.List;

public interface ReportsService extends RemoteService
{
  /**
   * @gwt.typeArgs <com.joejag.mavenstats.client.dto.ReportDTO>
   */
  List getReportNames();

  ReportDTO getReport(String reportName);

  /**
   * Utility/Convenience class.
   * Use ReportsService.App.getInstance() to access static instance of ReportsServiceAsync
   */
  public static class App
  {
    private static ReportsServiceAsync ourInstance = null;

    public static synchronized ReportsServiceAsync getInstance()
    {
      if (ourInstance == null)
      {
        ourInstance = (ReportsServiceAsync) GWT.create(ReportsService.class);
        ((ServiceDefTarget) ourInstance).setServiceEntryPoint(GWT.getModuleBaseURL() + "com.joejag.mavenstats.MavenStats/ReportsService");
      }
      return ourInstance;
    }
  }
}
